import axios from 'axios'
import Vue from 'vue'

//设置默认服务器IP
axios.defaults.baseURL = 'http://127.0.0.1:5000'

//设置bus线程
export let bus = new Vue()
//日期格式转换
export let getYYYYMMDD = datestr => {
    let time = new Date(datestr);
    return time.getFullYear() + '-' + zero(time.getMonth() + 1) + '-' + zero(time.getDate())
}

//日期格式转换时分秒
export let getYMDHSM = datestr => {
    let time = new Date(datestr);
    return time.getFullYear() + '-' + zero(time.getMonth() + 1) + '-' + zero(time.getDate()) + ' ' + zero(time.getHours()) + ':' + zero(time.getMinutes()) + ':' + zero(time.getSeconds())

}

//补0函数
export let zero = num => num < 10 ? '0' + num : num

//暴露axios
export default axios